package cn.luowb.checkchat.controller;

import cn.luowb.checkchat.common.result.Result;
import cn.luowb.checkchat.dao.entity.CommentDO;
import cn.luowb.checkchat.dto.req.CommentDTO;
import cn.luowb.checkchat.dto.req.CommentPageDTO;
import cn.luowb.checkchat.dto.resp.CommentPageVO;
import cn.luowb.checkchat.service.CommentService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("")
@Slf4j
public class CommentController {
    @Resource
    private CommentService commentService;

    @GetMapping("/public/comments")
    public Result<CommentPageVO> list(CommentPageDTO commentPageDTO) {
        return commentService.queryList(commentPageDTO);
    }

    @GetMapping("public/comments/replies")
    public Result<CommentPageVO> replies(CommentPageDTO commentPageDTO) {
        return commentService.commentReplies(commentPageDTO);
    }

    @DeleteMapping("/comment/delete/{id}")
    public Result delete(@PathVariable Long id) {
        return commentService.deleteById(id);
    }

    @PostMapping("/comment/create")
    public Result<CommentDO> savaComment(@RequestBody CommentDTO commentDTO) {
        return commentService.savaComment(commentDTO);
    }

}
